<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');
// load base class if needed
require_once( APPPATH . 'controllers/base/OperatorBase.php' );

class praktikum extends ApplicationBase {

    // constructor
    public function __construct() {
        parent::__construct();
        // load model
        $this->load->model('m_silabus');
        //--
        $this->smarty->assign('silabus', $this->m_silabus);
        // load library
        $this->load->library('tnotification');
        $this->load->library('pagination');
    }

    // halaman list data
    public function index() {
        // set page rules
        $this->_set_page_rule("R");
        // set template content
        $this->smarty->assign("template_content", "silabus/praktikum/index.html");
        // tahun ajaran
        $rs_tahun = $this->m_silabus->get_tahun_ajaran();
        $rs_tahun = !empty($rs_tahun) ? $rs_tahun : array("0" => array("tahun" => date('Y')));
        $this->smarty->assign('rs_tahun', $rs_tahun);
        // semester
        $sms = array(1, 2, 3, 4, 5, 6, 7, 8);
        $this->smarty->assign('rs_sms', $sms);
        // session
        $search = $this->tsession->userdata('search_silabus');
        $this->smarty->assign('search', $search);
        // params
        $tahun = !empty($search['tahun']) ? $search['tahun'] : "%";
        $semester = !empty($search['semester']) ? $search['semester'] : "%";
        $dosen_kd = $this->com_user['user_id'];
        //--
        $params = array($tahun, $semester, $dosen_kd);
        /* start of pagination --------------------- */
        // pagination
        $config['base_url'] = site_url("silabus/teori/index/");
        $config['total_rows'] = $this->m_silabus->get_total_data_makul_diampu($params);
        $config['uri_segment'] = 4;
        $config['per_page'] = 20;
        $this->pagination->initialize($config);
        $pagination['data'] = $this->pagination->create_links();
        // pagination attribute
        $start = $this->uri->segment(4, 0) + 1;
        $end = $this->uri->segment(4, 0) + $config['per_page'];
        $end = (($end > $config['total_rows']) ? $config['total_rows'] : $end);
        $pagination['start'] = ($config['total_rows'] == 0) ? 0 : $start;
        $pagination['end'] = $end;
        $pagination['total'] = $config['total_rows'];
        // pagination assign value
        $this->smarty->assign("pagination", $pagination);
        $this->smarty->assign("no", $start);
        /* end of pagination ---------------------- */
        // get data
        $params = array($tahun, $semester, $dosen_kd, ($start - 1), $config['per_page']);
        $result = $this->m_silabus->get_data_makul_diampu($params);
        $this->smarty->assign('rs_id', $result);
        // notification
        $this->tnotification->display_notification();
        $this->tnotification->display_last_field();
        // output
        parent::display();
    }

    // search proses
    public function search_process() {
        // set page rules
        $this->_set_page_rule("R");
        //--
        if ($this->input->post('save') == 'Cari') {
            // params
            $params = array(
                "tahun" => $this->input->post('tahun'),
                "semester" => $this->input->post('semester')
            );
            // set session
            $this->tsession->set_userdata('search_silabus', $params);
        } else {
            // unset session
            $this->tsession->unset_userdata('search_silabus');
        }
        // redirect
        redirect('silabus/praktikum');
    }

    // halaman pengaturan silabus
    public function manage($tahun = "", $semester = "", $dosen_kd = "", $makul_kd = "") {
        // set page rules
        $this->_set_page_rule("R");
        // set template content
        $this->smarty->assign("template_content", "silabus/praktikum/manage.html");
        // load javascript
        $this->smarty->load_javascript('resource/js/jquery/jquery-ui-1.9.2.custom.min.js');
        // load css 
        $this->smarty->load_style('jquery.ui/redmond/jquery-ui-1.8.13.custom.css');
        // params
        $this->smarty->assign('tahun', $tahun);
        $this->smarty->assign('semester', $semester);
        $this->smarty->assign('dosen_kd', $dosen_kd);
        $this->smarty->assign('makul_kd', $makul_kd);
        // mata kuliah
        $this->smarty->assign('makul', $this->m_silabus->get_detail_makul($makul_kd));
        // jurusan
        $this->smarty->assign('jurusan', $this->m_silabus->get_data_jurusan());
        // data
        $params = array(
            $tahun, $semester, $dosen_kd, $makul_kd, "praktikum"
        );
        $rs_id = $this->m_silabus->get_data_silabus($params);
        $this->smarty->assign('rs_id', $rs_id);
        // notification
        $this->tnotification->display_notification();
        $this->tnotification->display_last_field();
        // output
        parent::display();
    }

    // tambah data silabus
    public function proses_tambah_silabus() {
        // set page rules
        $this->_set_page_rule("C");
        // params
        $tahun = $this->input->post('tahun');
        $semester = $this->input->post('semester');
        $dosen_kd = $this->input->post('dosen_kd');
        $makul_kd = $this->input->post('makul_kd');
        $jurusan_kd = $this->input->post('jurusan_kd');
        $silabus_deskripsi = $this->input->post('silabus_deskripsi');
        //--
        $params = array(
            "praktikum", $semester, $tahun, $dosen_kd, $makul_kd, $jurusan_kd, $silabus_deskripsi, $this->com_user['user_id']
        );
        // insert
        $this->m_silabus->insert_data_silabus($params);
        $response = array(
            "tahun" => $tahun, "semester" => $semester,
            "dosen_kd" => $dosen_kd, "makul_kd" => $makul_kd
        );
        echo json_encode($response);
    }

    // halaman detail silabus
    public function detail($silabus_kd = "") {
        // set page rules
        $this->_set_page_rule("R");
        // set template content
        $this->smarty->assign("template_content", "silabus/praktikum/detail.html");
        // info
        $rs_info = $this->m_silabus->get_detail_info_silabus($silabus_kd);
        $this->smarty->assign('rs_info', $rs_info);
        // data
        $rs_id = $this->m_silabus->get_data_item_silabus($silabus_kd);
        $this->smarty->assign('rs_id', $rs_id);
        // notification
        $this->tnotification->display_notification();
        $this->tnotification->display_last_field();
        // output
        parent::display();
    }

    // halaman tambah detail silabus
    public function detail_add($silabus_kd = "") {
        // set page rules
        $this->_set_page_rule("C");
        // set template content
        $this->smarty->assign("template_content", "silabus/praktikum/detail_add.html");
        // load javascript
        $this->smarty->load_javascript('resource/js/jquery/jquery-ui-1.9.2.custom.min.js');
        // load css 
        $this->smarty->load_style('jquery.ui/redmond/jquery-ui-1.8.13.custom.css');
        // info
        $rs_info = $this->m_silabus->get_detail_info_silabus($silabus_kd);
        $this->smarty->assign('rs_info', $rs_info);
        // notification
        $this->tnotification->display_notification();
        $this->tnotification->display_last_field();
        // output
        parent::display();
    }

    // proses tambah detail silabus
    public function detail_add_process() {
        // set page rules
        $this->_set_page_rule("C");
        // cek input
        $this->tnotification->set_rules('silabus_kd', 'Kode Silabus', 'required');
        $this->tnotification->set_rules('minggu', 'Minggu', 'numeric|max_length[2]');
        $this->tnotification->set_rules('kompetensi_dasar', 'Kompetensi Dasar', 'max_length[100]');
        $this->tnotification->set_rules('materi[]', 'Materi Pokok');
        $this->tnotification->set_rules('indikator[]', 'Indikator Kompetensi');
        $this->tnotification->set_rules('sumber[]', 'Sumber');
        $this->tnotification->set_rules('evaluasi', 'Evaluasi/Penilaian', 'max_length[100]');
        // proses
        if ($this->tnotification->run() !== FALSE) {
            // params
            $params = array(
                $this->input->post('silabus_kd'), $this->input->post('minggu'),
                $this->input->post('kompetensi_dasar'), $this->input->post('evaluasi'),
                $this->input->post('keterangan'), $this->com_user['user_id']
            );
            // insert
            if ($this->m_silabus->insert_data_item_silabus($params)) {
                $silabus_detail_kd = $this->m_silabus->get_last_inserted_id();
                // materi pokok
                $materi = $this->input->post('materi');
                if (!empty($materi)) {
                    foreach ($materi as $key => $value) {
                        // insert
                        $params = array($silabus_detail_kd, $value, $this->com_user['user_id']);
                        $this->m_silabus->insert_materi_detail($params);
                    }
                }
                // indikator kompetensi
                $indikator = $this->input->post('indikator');
                if (!empty($indikator)) {
                    foreach ($indikator as $key => $value) {
                        // insert
                        $params = array($silabus_detail_kd, $value, $this->com_user['user_id']);
                        $this->m_silabus->insert_indikator_detail($params);
                    }
                }
                // sumber
                $sumber = $this->input->post('sumber');
                if (!empty($sumber)) {
                    foreach ($sumber as $key => $value) {
                        // insert
                        $params = array($silabus_detail_kd, $value, $this->com_user['user_id']);
                        $this->m_silabus->insert_sumber_detail($params);
                    }
                }
                // upload file
                if (!empty($_FILES['file']['tmp_name'])) {
                    // load
                    $this->load->library('tupload');
                    //path
                    $path = 'resource/doc/silabus/praktikum/';
                    // upload config
                    $config['upload_path'] = $path;
                    $config['allowed_types'] = 'pdf';
                    $config['max_size'] = '4096';
                    $config['file_name'] = $silabus_detail_kd;
                    $this->tupload->initialize($config);
                    // process upload images
                    if ($this->tupload->do_upload('file')) {
                        // success
                        $this->tnotification->delete_last_field();
                        $this->tnotification->sent_notification('success', 'Data berhasil disimpan');
                    } else {
                        // jika gagal
                        $this->tnotification->set_error_message($this->tupload->display_errors());
                    }
                }
                // sukses
                $this->tnotification->delete_last_field();
                $this->tnotification->sent_notification("success", "Data berhasil disimpan");
            } else {
                // default error
                $this->tnotification->sent_notification("error", "Data gagal disimpan");
            }
        } else {
            // default error
            $this->tnotification->sent_notification("error", "Data gagal disimpan");
        }
        // redirect
        redirect('silabus/praktikum/detail_add/' . $this->input->post('silabus_kd'));
    }

    // halaman edit detail silabus
    public function detail_edit($silabus_kd = "", $silabus_detail_kd = "") {
        // set page rules
        $this->_set_page_rule("U");
        // set template content
        $this->smarty->assign("template_content", "silabus/praktikum/detail_edit.html");
        // load javascript
        $this->smarty->load_javascript('resource/js/jquery/jquery-ui-1.9.2.custom.min.js');
        // load css 
        $this->smarty->load_style('jquery.ui/redmond/jquery-ui-1.8.13.custom.css');
        // info
        $rs_info = $this->m_silabus->get_detail_info_silabus($silabus_kd);
        $this->smarty->assign('rs_info', $rs_info);
        // data 
        $result = $this->m_silabus->get_detail_data_silabus($silabus_detail_kd);
        $this->smarty->assign('result', $result);
        // materi pokok
        $rs_materi = $this->m_silabus->get_data_materi($silabus_detail_kd);
        $this->smarty->assign('rs_materi', $rs_materi);
        $this->smarty->assign('total_materi', count($rs_materi));
        // indikator kompetensi
        $rs_indikator = $this->m_silabus->get_data_indikator($silabus_detail_kd);
        $this->smarty->assign('rs_indikator', $rs_indikator);
        $this->smarty->assign('total_indikator', count($rs_indikator));
        // sumber
        $rs_sumber = $this->m_silabus->get_data_sumber($silabus_detail_kd);
        $this->smarty->assign('rs_sumber', $rs_sumber);
        $this->smarty->assign('total_sumber', count($rs_sumber));
        // get file
        $file_path = 'resource/doc/silabus/praktikum/' . $silabus_detail_kd . '.pdf';
        //--
        $link = 'silabus/praktikum/download_files/' . $silabus_detail_kd;
        if (is_file($file_path)) {
            $url = site_url($link);
            $file_download = '<a href="' . $url . '">Terdapat file yang sudah diupload.</a>';
        } else {
            $file_download = '<em>File belum diupload!</em>';
        }
        $this->smarty->assign('file_download', $file_download);
        // notification
        $this->tnotification->display_notification();
        $this->tnotification->display_last_field();
        // output
        parent::display();
    }

    // proses edit silabus
    public function detail_edit_process() {
        // set page rules
        $this->_set_page_rule("U");
        // cek input
        $this->tnotification->set_rules('silabus_kd', 'Kode Silabus', 'required');
        $this->tnotification->set_rules('minggu', 'Minggu', 'numeric|max_length[2]');
        $this->tnotification->set_rules('kompetensi_dasar', 'Kompetensi Dasar', 'max_length[100]');
        $this->tnotification->set_rules('materi[]', 'Materi Pokok');
        $this->tnotification->set_rules('indikator[]', 'Indikator Kompetensi');
        $this->tnotification->set_rules('sumber[]', 'Sumber');
        $this->tnotification->set_rules('evaluasi', 'Evaluasi/Penilaian', 'max_length[100]');
        $this->tnotification->set_rules('silabus_detail_kd', 'Kode Detail Silabus', 'required');
        // proses
        if ($this->tnotification->run() !== FALSE) {
            // params
            $params = array(
                $this->input->post('minggu'),
                $this->input->post('kompetensi_dasar'), $this->input->post('evaluasi'),
                $this->input->post('keterangan'), $this->com_user['user_id'],
                $this->input->post('silabus_detail_kd')
            );
            // update
            if ($this->m_silabus->update_data_item_silabus($params)) {
                $silabus_detail_kd = $this->input->post('silabus_detail_kd');
                // materi pokok
                $materi = $this->input->post('materi');
                if (!empty($materi)) {
                    // delete
                    $this->m_silabus->delete_materi_detail($silabus_detail_kd);
                    foreach ($materi as $key => $value) {
                        // insert
                        $params = array($silabus_detail_kd, $value, $this->com_user['user_id']);
                        $this->m_silabus->insert_materi_detail($params);
                    }
                }
                // indikator kompetensi
                $indikator = $this->input->post('indikator');
                if (!empty($indikator)) {
                    // delete
                    $this->m_silabus->delete_indikator_detail($silabus_detail_kd);
                    foreach ($indikator as $key => $value) {
                        // insert
                        $params = array($silabus_detail_kd, $value, $this->com_user['user_id']);
                        $this->m_silabus->insert_indikator_detail($params);
                    }
                }
                // sumber
                $sumber = $this->input->post('sumber');
                if (!empty($sumber)) {
                    // delete
                    $this->m_silabus->delete_sumber_detail($silabus_detail_kd);
                    foreach ($sumber as $key => $value) {
                        // insert
                        $params = array($silabus_detail_kd, $value, $this->com_user['user_id']);
                        $this->m_silabus->insert_sumber_detail($params);
                    }
                }
                // upload file
                if (!empty($_FILES['file']['tmp_name'])) {
                    // load
                    $this->load->library('tupload');
                    //path
                    $path = 'resource/doc/silabus/praktikum/';
                    // upload config
                    $config['upload_path'] = $path;
                    $config['allowed_types'] = 'pdf';
                    $config['max_size'] = '4096';
                    $config['file_name'] = $silabus_detail_kd;
                    $this->tupload->initialize($config);
                    // process upload images
                    if ($this->tupload->do_upload('file')) {
                        // success
                        $this->tnotification->delete_last_field();
                        $this->tnotification->sent_notification('success', 'Data berhasil disimpan');
                    } else {
                        // jika gagal
                        $this->tnotification->set_error_message($this->tupload->display_errors());
                    }
                }
                // sukses
                $this->tnotification->delete_last_field();
                $this->tnotification->sent_notification("success", "Data berhasil disimpan");
            } else {
                // default error
                $this->tnotification->sent_notification("error", "Data gagal disimpan");
            }
        } else {
            // default error
            $this->tnotification->sent_notification("error", "Data gagal disimpan");
        }
        // redirect
        redirect('silabus/praktikum/detail_edit/' . $this->input->post('silabus_kd') . '/' . $this->input->post('silabus_detail_kd'));
    }

    // halaman hapus detail silabus
    public function detail_delete($silabus_kd = "", $silabus_detail_kd = "") {
        // set page rules
        $this->_set_page_rule("D");
        // set template content
        $this->smarty->assign("template_content", "silabus/praktikum/detail_delete.html");
        // load javascript
        $this->smarty->load_javascript('resource/js/jquery/jquery-ui-1.9.2.custom.min.js');
        // load css 
        $this->smarty->load_style('jquery.ui/redmond/jquery-ui-1.8.13.custom.css');
        // info
        $rs_info = $this->m_silabus->get_detail_info_silabus($silabus_kd);
        $this->smarty->assign('rs_info', $rs_info);
        // data 
        $result = $this->m_silabus->get_detail_data_silabus($silabus_detail_kd);
        $this->smarty->assign('result', $result);
        // materi pokok
        $rs_materi = $this->m_silabus->get_data_materi($silabus_detail_kd);
        $this->smarty->assign('rs_materi', $rs_materi);
        $this->smarty->assign('total_materi', count($rs_materi));
        // indikator kompetensi
        $rs_indikator = $this->m_silabus->get_data_indikator($silabus_detail_kd);
        $this->smarty->assign('rs_indikator', $rs_indikator);
        $this->smarty->assign('total_indikator', count($rs_indikator));
        // sumber
        $rs_sumber = $this->m_silabus->get_data_sumber($silabus_detail_kd);
        $this->smarty->assign('rs_sumber', $rs_sumber);
        $this->smarty->assign('total_sumber', count($rs_sumber));
        // get file
        $file_path = 'resource/doc/silabus/praktikum/' . $silabus_detail_kd . '.pdf';
        //--
        $link = 'silabus/praktikum/download_files/' . $silabus_detail_kd;
        if (is_file($file_path)) {
            $url = site_url($link);
            $file_download = '<a href="' . $url . '">Terdapat file yang sudah diupload.</a>';
        } else {
            $file_download = '<em>File belum diupload!</em>';
        }
        $this->smarty->assign('file_download', $file_download);
        // notification
        $this->tnotification->display_notification();
        $this->tnotification->display_last_field();
        // output
        parent::display();
    }

    // proses hapus detail silabus
    public function detail_delete_process() {
        // set page rules
        $this->_set_page_rule("D");
        // cek input
        $this->tnotification->set_rules('silabus_kd', 'Kode Silabus', 'required');
        $this->tnotification->set_rules('silabus_detail_kd', 'Kode Detail Silabus', 'required');
        // proses
        if ($this->tnotification->run() !== FALSE) {
            // params
            $silabus_detail_kd = $this->input->post('silabus_detail_kd');
            // delete
            if ($this->m_silabus->delete_data_item_silabus($silabus_detail_kd)) {
                // hapus file
                $file_path = 'resource/doc/silabus/praktikum/' . $silabus_detail_kd . '.pdf';
                if (is_file($file_path)) {
                    unlink($file_path);
                }
                // sukses
                $this->tnotification->delete_last_field();
                $this->tnotification->sent_notification("success", "Data berhasil dihapus");
                // redirect
                redirect('silabus/praktikum/detail/' . $this->input->post('silabus_kd'));
            } else {
                // default error
                $this->tnotification->sent_notification("error", "Data gagal dihapus");
            }
        } else {
            // default error
            $this->tnotification->sent_notification("error", "Data gagal dihapus");
        }
        // redirect
        redirect('silabus/praktikum/detail_delete/' . $this->input->post('silabus_kd') . '/' . $this->input->post('silabus_detail_kd'));
    }

    // cetak silabus format pdf
    public function cetak_pdf($silabus_kd = "") {
        //set rule
        $this->_set_page_rule("R");
        // load library
        $this->load->library('tcpdf');
        // info
        $rs_info = $this->m_silabus->get_detail_info_silabus($silabus_kd);
        // data
        $rs_id = $this->m_silabus->get_data_item_silabus($silabus_kd);
        if (empty($rs_id)) {
            $this->tnotification->sent_notification("error", "Tidak ada data silabus yang dicetak !");
            // redirect
            redirect('silabus/praktikum/detail/' . $silabus_kd);
        }
        /*
         *  print out
         */
        // page setting
        $this->tcpdf->SetPrintHeader(false);
        $this->tcpdf->SetPrintFooter(false);
        $this->tcpdf->SetDisplayMode('real');
        $this->tcpdf->SetMargins(10, 10, 10, false);
        $this->tcpdf->SetFont('helvetica', '', 10);
        $this->tcpdf->SetAutoPageBreak(TRUE, 0);
        $this->tcpdf->AddPage('L', 'F4');
        // html content
        $html = '<table cellpadding="2">';
        $html .= '  <tr>';
        $html .= '      <td width="15%"><b>MATA KULIAH</b></td>';
        $html .= '      <td width="3%" align="center"><b>:</b></td>';
        $html .= '      <td width="82%"><b>' . $rs_info['makul_nm'] . ' (PRAKTIKUM)</b></td>';
        $html .= '  </tr>';
        $html .= '  <tr>';
        $html .= '      <td><b>SKS</b></td>';
        $html .= '      <td align="center"><b>:</b></td>';
        $html .= '      <td><b>' . $rs_info['makul_sks'] . '</b></td>';
        $html .= '  </tr>';
        $html .= '  <tr>';
        $html .= '      <td><b>JURUSAN</b></td>';
        $html .= '      <td align="center"><b>:</b></td>';
        $html .= '      <td><b>' . $rs_info['jurusan_nm'] . '</b></td>';
        $html .= '  </tr>';
        $html .= '  <tr>';
        $html .= '      <td><b>DESKRIPSI</b></td>';
        $html .= '      <td align="center"><b>:</b></td>';
        $html .= '      <td><b>' . $rs_info['silabus_deskripsi'] . '</b></td>';
        $html .= '  </tr>';
        $html .= '  <tr>';
        $html .= '      <td></td>';
        $html .= '      <td align="center"></td>';
        $html .= '      <td></td>';
        $html .= '  </tr>';
        $html .= '</table>';
        $html .= '<table cellpadding="2" border="0.5" style="font-size: 8;">';
        $html .= '  <tr>';
        $html .= '      <td width="5%" align="center"><b>MINGGU</b></td>';
        $html .= '      <td width="20%" align="center"><b>KOMPETENSI DASAR</b></td>';
        $html .= '      <td width="20%" align="center"><b>MATERI POKOK</b></td>';
        $html .= '      <td width="25%" align="center"><b>INDIKATOR KOMPETENSI</b></td>';
        $html .= '      <td width="10%" align="center"><b>SUMBER</b></td>';
        $html .= '      <td width="10%" align="center"><b>PENILAIAN</b></td>';
        $html .= '      <td width="10%" align="center"><b>KETERANGAN</b></td>';
        $html .= '  </tr>';
        // DATA
        foreach ($rs_id as $data) {
            $html .= '<tr>';
            $html .= '  <td align="center">' . $data['minggu'] . '</td>';
            $html .= '  <td>- ' . $data['kompetensi_dasar'] . '</td>';
            // materi pokok
            $rs_materi = $this->m_silabus->get_data_materi($data['silabus_detail_kd']);
            $html .= '  <td>';
            foreach ($rs_materi as $materi) {
                $html .= '- ' . $materi['materi_content'] . '<br />';
            }
            $html .= '  </td>';
            // indikator kompetensi
            $rs_indikator = $this->m_silabus->get_data_indikator($data['silabus_detail_kd']);
            $html .= '  <td>';
            foreach ($rs_indikator as $indikator) {
                $html .= '' . $indikator['indikator_content'] . '<br />';
            }
            $html .= '  </td>';
            // sumber
            $rs_sumber = $this->m_silabus->get_data_sumber($data['silabus_detail_kd']);
            $html .= '  <td>';
            foreach ($rs_sumber as $sumber) {
                $html .= '- ' . $sumber['sumber_content'] . '<br />';
            }
            $html .= '  </td>';
            $html .= '  <td>- ' . $data['evaluasi'] . '</td>';
            $html .= '  <td>- ' . $data['keterangan'] . '</td>';
            $html .= '</tr>';
        }
        $html .= '</table>';
        // filename
        $filename = str_replace(" ", "_", $rs_info['silabus_deskripsi']);
        // write
        $this->tcpdf->writeHTML($html, true, false, true, false, '');
        // download output
        $this->tcpdf->Output('' . strtoupper($filename) . '_(PRAKTIKUM).pdf', 'D');
    }

    /*
     * UTILITY
     */

    // download files
    public function download_files($silabus_detail_kd = "") {
        // set page rules
        $this->_set_page_rule("R");
        // get file
        $file_path = 'resource/doc/silabus/praktikum/' . $silabus_detail_kd . '.pdf';
        // info
        $info = $this->m_silabus->get_detail_data_silabus($silabus_detail_kd);
        $filename = $info['minggu'] . "_" . strtoupper(str_replace(" ", "_", $info['kompetensi_dasar']) . "_(PRAKTIKUM)");
        // download
        header('Content-type: application/octet-stream');
        header('Content-Disposition: attachment; filename="' . $filename . '.pdf');
        readfile($file_path);
    }

}